package x.ovo.wechat.bot.http.request.core;

import cn.hutool.core.net.url.UrlBuilder;
import x.ovo.wechat.bot.common.Constant;
import x.ovo.wechat.bot.common.http.request.ApiRequest;
import x.ovo.wechat.bot.common.http.session.LoginSession;

import java.util.Map;
import java.util.function.Function;

/**
 * 注销请求
 *
 * @author ovo, created by 2024/05/03
 */
public class LogoutRequest extends ApiRequest<Void> {


    public LogoutRequest(LoginSession session) {
        super(session);
    }

    @Override
    public String getUrl() {
        return UrlBuilder.of(this.session.getUrl())
                .addPath(Constant.LOGOUT)
                .addQuery("redirect", 1)
                .addQuery("type", 0)
                .addQuery("skey", this.session.getSKey())
                .build();
    }

    @Override
    public Map<String, Object> getParameters() {
        super.addParameter("uin", this.session.getWxUin())
                .addParameter("sid", this.session.getWxSid());
        return super.getParameters();
    }

    @Override
    public Function<String, Void> responseHandler() {
        return null;
    }
}
